package com.znsd.zl.statisticshouse.controller;



import com.znsd.zl.statisticshouse.entity.HouseRentEntity;
import com.znsd.zl.statisticshouse.entity.vo.RentVo;
import com.znsd.zl.statisticshouse.service.IHouseRentService;
import com.znsd.zl.utils.BaseController;
import com.znsd.zl.utils.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @ClassName HouseStatisticsController
 * @Description 房源统计Controller层
 * @author xyx
 * @date 2020-08-24 10:53:55
 * @Version v1.0
 */
@RestController
@RequestMapping("/zl/house/statistics")
public class HouseStatisticsController extends BaseController<IHouseRentService, HouseRentEntity, Integer> {

	@Override
	@GetMapping("/{pageNum}/{pageSize}")
	public R pageFind(Map<String, Object> params,
	                  @PathVariable(name = "pageNum") Integer pageNum,
	                  @PathVariable(name = "pageSize") Integer pageSize) {
		List<RentVo> all;
		try{
			all = service.findAll(pageNum, pageSize);
		}catch (Exception e) {
			e.printStackTrace();
			return R.error("服务器异常，请稍后重试");
		}
		return R.ok().put("list",all);
	}

	@GetMapping("/count")
	public Integer count() {
		int count = service.counts();
		return count;
	}

}
